Convert JSON parsing failures from assertions to exceptions#7531
Convert JSON parsing failures from assertions to exceptions#7531
Conversation
This allows some useful error reporting with bad source maps. The JSON exception is converted to the existing map parse exception by the source map parser, allowing a unified interface. Also add several tests of bogus source maps.
|
|
||
| next = peek(); | ||
| if (next == ';') { | ||
| throw MapParseException("Unexpected mapping for 2nd generated line"); |
There was a problem hiding this comment.
A generated JS file can have multiple lines. Mappings for each line are separated by a ; character. But wasm files are treated as if they have only one line, and the column number is treated as the binary offset. I'll add a comment.
| if(BUILD_FUZZTEST) | ||
| set(unittest_SOURCES ${unittest_SOURCES} type-domains.cpp) | ||
| else() | ||
| set(unittest_SOURCES ${unittest_SOURCES} source-map.cpp) |
There was a problem hiding this comment.
@tlively I've had to exclude this file from fuzztest builds, because it uses the gmock-matchers.h header (gmock is included with "standard" gtest but not with the one bundled with fuzztest). I tried including the gmock header along with the fuzztest gtest, but it seems to depend on some kind of internal gtest bit that the fuzztest gtest doesn't have. Do you know if fuzztest's bundled gtest is some sort of subset, or if they have any recommendations for use with gtest features they don't support themselves? Or maybe this is just WAI, and the intention is that fuzztests are logically separate enough from regular unit tests that it just makes sense to build them separately.
There was a problem hiding this comment.
No, I don't know the details of why fuzztest's bundled gtest is different from normal gtest, nor have I seen any recommendations for this. It's definitely not WAI, though. fuzztests are supposed to coexist peacefully with normal gtests AFAICT.
It's probably fine excluding the file to work around the problem for now. The fuzztest build isn't important enough (yet) to spend time on. It would be good to add a comment explaining the problem, though.
This allows some useful error reporting with bad source maps.
The JSON exception is converted to the existing map parse exception by the
source map parser, allowing a unified interface. Also add several tests of
bogus source maps.